#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n, cnt, tot, maxn, minn, tm[110];
void dfs(int res, int sum, int target, int p)
{
    if (res == 0)
    {
        printf("%d", target);
        exit(0);
    }
    if (sum == target)
    {
        dfs(res - 1, 0, target, maxn);
        return;
    }
    for (int i = p; i >= minn; i--)
    {
        if (tm[i] && i + sum <= target)
        {
            tm[i]--;
            dfs(res, sum + i, target, i);
            tm[i]++;
            if (sum == 0 || sum + i == target)
            {
                break;
            }
        }
    }
    return;
}
inline void solution()
{
    scanf("%d", &n);
    minn = 70;
    int temp;
    while (n--)
    {
        scanf("%d", &temp);
        if (temp <= 50)
        {
            cnt++;
            tm[temp]++;
            tot += temp;
            maxn = maxn > temp ? maxn : temp;
            minn = minn < temp ? minn : temp;
        }
    }
    temp = tot * 2;
    for (int i = maxn; i <= temp; i++)
    {
        if (tot % i == 0)
        {
            dfs(tot / i, 0, i, maxn);
        }
    }
    printf("%d", tot);
}

int main()
{
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}